package cn.eleven.mapper;

import cn.eleven.entity.ForumPost;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


@Mapper
@Repository
public interface ForumPostMapper extends BaseMapper<ForumPost> {
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "id", property = "users", many = @Many(select = "cn.eleven.mapper.UserMapper.selectByForumPostId"))
    })
    @Select("SELECT * FROM forum_post WHERE id= #{id}")
    ForumPost getForumPostById(int id);
    @Select("SELECT * FROM forum_post WHERE user_id = #{userId}")
    List<ForumPost> getForumPostByUserId(int userId);
}